package cn.tedu.travelsystem.base.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.concurrent.TimeUnit;

@Component
public class CacheUtil {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;


    public void setExpire(String key, Serializable value,long timeout){
        redisTemplate.opsForValue().set(key,value,timeout, TimeUnit.SECONDS);
    }
    public void set(String key, Serializable value){
        redisTemplate.opsForValue().set(key,value);
    }

    public Object get(String key) {
        return redisTemplate.opsForValue().get(key);
    }

}
